<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@page import="com.hz.util.ParamUtil"%>
<%@page import="com.hz.model.User"%>
<%@page import="com.hz.control.ServiceControl"%>
<%@page import="com.hz.control.UserControl"%>
<%@page import="java.util.Collection"%>
<%@page import="com.hz.model.Service"%>
<%@page import="java.util.Iterator"%>
<%@page import="com.hz.model.Activity"%>
<%@page import="com.hz.control.ActivityControl"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="../../volunteer/js/core.js"></script>
<link rel='stylesheet' type='text/css' href='../../css/zhengs.css'/>
<script>
function btnPrintClick(){  
	bdhtml=window.document.body.innerHTML;    
    sprnstr="<!--startprint-->";    
    eprnstr="<!--endprint-->";    
    prnhtml=bdhtml.substring(bdhtml.indexOf(sprnstr)+17);    
    prnhtml=prnhtml.substring(0,prnhtml.indexOf(eprnstr));    
    window.document.body.innerHTML=prnhtml;    
    window.print();    
}  
</script>
<title>服务证书</title>
</head>
<body>
<%
        User cu = (User)session.getAttribute("user");
        int uid = ParamUtil.getInt(request,"uid",cu.getId());
        User u = UserControl.getUserInformation(uid);
        String year=ParamUtil.getString(request,"year","0");
%>
<!--startprint-->
<section class='sec pr'>
<div class='pa tl'><img src='../../css/images/tl.png'/></div>
<div class='pa tr'><img src='../../css/images/tr.png'/></div>
<div class='pa bl'><img src='../../css/images/bl.png'/></div>
<div class='pa br'><img src='../../css/images/br.png'/></div>
<div class="pa txt">认证书</div>
<div class='pa c'><img src='../../css/images/c.png'/></div>
<article>
<br/>
<p class='content'>我愿意成为一名光荣的志愿者。我承诺：尽已所能，不计报酬，帮助他人，服务社会。实行志愿精神，传播先进文化，为建设团结互助、平等友爱、共同前进的美好社会贡献力量。</p> 

<h1 class='name'><%=u.getRealname() %>同学：</h1>
<p class="tag">以下是您在红烛协会的志愿者经历：</p>
<table class='expr'>
<thead>
<tr>
<td>活动</td>
<td>时间</td>
<td>具体职位</td>
<td>服务时长(小时)</td>
</tr>
</thead>
<tbody>
<%
        Collection<Service> slist = ServiceControl.oneGetActivitiesByYears(uid,year);
       if(slist.size()>0){
        Iterator<Service> it = slist.iterator();
        while(it.hasNext()){
            Service s = it.next();
            Activity a = ActivityControl.getActivityInformation(s.getActId());   
%>
<tr>
<td width='40%'><%=a.getActName() %></td>
<td width='30%'><%=a.getStartTime().length()>10?a.getStartTime().substring(0,10):a.getStartTime() %></td>
<td><%=s.getDuty() %></td>
<td><%=ServiceControl.getHours(a.getId(),cu.getId()) %></td>
</tr>
  <%         
        }}else{
        	out.print("<tr><td colspan='4'>无</td></tr>");
        }
 %>  
 </tbody>
 </table> 
 <p class="content">作为一名光荣的东北师范大学红烛志愿者协会的志愿者，您以实际行动弘扬奉献、友爱、互助、进步的志愿服务精神。您<%out.print(year.equals("0")?"自加入红烛志愿者协会以来，":year+"年"); %>累计服务<%=ServiceControl.getTotalHoursByYear(uid,3,year) %>小时，
 <%
  if(!year.equals("0")){
 %>被评为<%out.print(ServiceControl.getTotalHoursByYear(uid,3,year)>20?(int)ServiceControl.getTotalHoursByYear(uid,3,year)/20:"");%>星级志愿者，
 <%} %>
 特向您致以深深的谢意！</p>                                                                                                                                                                                            
</article>
<aside class='sub pa clearfix'>
<p class='tuanw'>共青团东北师范大学委员会</p>
<p class='xieh'>东北师范大学红烛志愿者协会</p>
<p class='date'><input type=text class='text'/>年<input type=text class='text'/>月<input type=text class='text'/>日</p>  
</aside> 
</section>
<!--endprint-->
<div align="center"><input id="btnPrint" value="打印" type="button" onclick="btnPrintClick()";/>  <br/></div>
<br/><br/>
</body>
</html>